package com.bdy.lm.taximanager.util;

import java.io.FileDescriptor;
import java.io.FileInputStream;
import java.io.FileOutputStream;

/**
 * Created by Administrator on 2016/8/12.
 */
public class GetSerialData {

    serial Selfmade = new serial();
    String data = "无数据";

    public GetSerialData(){
        Selfmade.Open(6, 115200);
        System.out.println("初始化成功");
    }

    public String getSerialData(){
        int[] RX = Selfmade.Read();
        if(RX == null){
            System.out.println("无串口数据");
            return data;
        }else {
            data = new String(RX, 0, RX.length);
            System.out.println("读取正常，数据为:"+data);
            return data;
        }
    }

    static {
        System.loadLibrary("serial");
    }

}
